package com.yanqu.road.server.cmd.activity.stronghold.wild;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.pb.activity.StrongholdWarProto;
import com.yanqu.road.pb.rank.UnionActivityRankProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.strongholdwar.StrongholdActivityMgr;
import com.yanqu.road.server.manger.activity.strongholdwar.StrongholdWarMgr;
import com.yanqu.road.server.manger.cross.CrossDataMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.server.protocol.Protocol;

import java.math.BigInteger;

@Cmd(code = GameProtocol.S_STRONGHOLD_WAR_SILVER_DONATE_DATA, desc = "银两捐献详情")
public class GetStrongholdSilverDonateDataCmd extends AbstractCommand {
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ActivityInfo activityInfo = StrongholdActivityMgr.getOpenActivityInfo();
       /* if (StrongholdActivityMgr.isAfterWildTime()) {
            sendLocalData(player, activityInfo.getActivityId());
            return;
        }*/

        int activityId = activityInfo.getActivityId();
        StrongholdWarProto.CrossStrongholdSilverDonateRankReq.Builder req = StrongholdWarProto.CrossStrongholdSilverDonateRankReq.newBuilder();
        req.setActivityId(activityId);
        req.setUnionId(player.getUserInfo().getUnionUid());
        player.sendUnionActivityGroupPacket(CrossProtocol.C_CROSS_STRONGHOLD_SILVER_UNION_RANK, req, req.getActivityId());
    }

//    private void sendLocalData(GamePlayer player, int activityId) {
//        String unionUid = player.getUserInfo().getUnionUid();
//        UnionActivityRankProto.UnionActivityRankListMsg tempList = CrossDataMgr.getCrossActivityUnionConditionTypeRankList(activityId, StrongholdActivityMgr.CONDITION_TYPE_SILVER_UNION);
//        BigInteger myUnionValue = BigInteger.ZERO;
//        for (UnionActivityRankProto.UnionActivityRankTempMsg tempMsg : tempList.getRankListList()) {
//            if (tempMsg.getUnionUid().equals(unionUid)) {
//                myUnionValue = new BigInteger(tempMsg.getValue());
//            }
//        }
//        StrongholdWarProto.StrongholdSilverDonateDataRespMsg.Builder resp = StrongholdWarProto.StrongholdSilverDonateDataRespMsg.newBuilder();
//        StrongholdWarProto.StrongholdSilverDonateDataMsg.Builder msg = StrongholdWarProto.StrongholdSilverDonateDataMsg.newBuilder();
//        msg.setRank(StrongholdWarMgr.getSilverRank(activityId, unionUid));
//        msg.setTotalDonate(myUnionValue.toString());
//        resp.setData(msg);
//        player.sendChannelPacket(ClientProtocol.U_STRONGHOLD_WAR_SILVER_DONATE_DATA, resp);
//    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
